@extends('layouts.base') @section('content') @parent
<div id="wrapper">
    <div class="main-content container">
        <div class="row small-spacing">
            <div class="col-lg-9 col-xs-9">
                <div class="box-content">
                    <h4 class="box-title text-warning">
                        发文队列&nbsp; &nbsp;
                        <button type="button" class="btn btn-default waves-effect waves-light" data-toggle="modal"
                                data-target="#addTask">Add
                        </button>
                    </h4>
                    <!-- /.box-title -->
                    <div class="col-xs-12">
                        <div class="box-content">
                            <div id="example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap">
                                <div class="row">
                                    <div class="col-sm-12">
                                        <div class="alert alert-info" role="alert">
                                            <strong>提示信息：</strong> 已过期的队列可以删除，但不可以编辑
                                        </div>
                                        <table id="example2"
                                               class="table table-striped table-bordered display dataTable"
                                               style="width:100%" role="grid" aria-describedby="example_info">
                                            <thead>
                                            <tr role="row">
                                                <th class="sorting" tabindex="0" aria-controls="example" rowspan="1"
                                                    colspan="1" aria-sort="ascending"
                                                    aria-label="Name: activate to sort column descending">Id
                                                </th>
                                                <th class="sorting" tabindex="0" aria-controls="example" rowspan="1"
                                                    colspan="1"
                                                    aria-label="Position: activate to sort column ascending">站点
                                                </th>
                                                <th class="sorting" tabindex="0" aria-controls="example" rowspan="1"
                                                    colspan="1"
                                                    aria-label="Office: activate to sort column ascending">分类
                                                </th>
                                                <th class="sorting" tabindex="0" aria-controls="example" rowspan="1"
                                                    colspan="1"
                                                    aria-label="Age: activate to sort column ascending">发布时间
                                                </th>
                                                <th class="sorting" tabindex="0" aria-controls="example" rowspan="1"
                                                    colspan="1"
                                                    aria-label="Start date: activate to sort column ascending">发布状态
                                                </th>
                                                <th class="sorting" tabindex="0" aria-controls="example" rowspan="1"
                                                    colspan="1"
                                                    aria-label="Start date: activate to sort column ascending">是否过期
                                                </th>
                                                <th class="sorting" tabindex="0" aria-controls="example" rowspan="1"
                                                    colspan="1"
                                                    aria-label="Salary: activate to sort column ascending">操作
                                                </th>
                                            </tr>
                                            </thead>
                                            @if(count($datas)>8)
                                                <tfoot>
                                                <tr>
                                                    <th rowspan="1" colspan="1">Id</th>
                                                    <th rowspan="1" colspan="1">站点</th>
                                                    <th rowspan="1" colspan="1">分类</th>
                                                    <th rowspan="1" colspan="1">发布时间</th>
                                                    <th rowspan="1" colspan="1">发布状态</th>
                                                    <th rowspan="1" colspan="1">是否过期</th>
                                                    <th rowspan="1" colspan="1">操作</th>
                                                </tr>
                                                </tfoot>
                                            @endif
                                            <tbody>
                                            @foreach($datas as $key=>$data)
                                                <tr role="row" class="{{$key%2==0?'odd':'even'}}">
                                                    <td class="sorting_1">{{$data['id']}}</td>
                                                    <td>{{$data['site']['name']}}</td>
                                                    <td>{{$data['category']['name']}}</td>
                                                    <td>{{$data['pubtime']}}</td>
                                                    <td>{!! $data['status'] !!}</td>
                                                    <td>{{$data['is_out']==0?"未过期":"过期"}}</td>
                                                    <td>
                                                        @if(!$data['is_out'])
                                                            <button type="button"
                                                                    class="editbtn btn btn-info btn-xs waves-effect waves-light"
                                                                    data-toggle="modal" data-target="#editstartend"
                                                                    data-id="{{$data['id']}}"
                                                                    data-site="{{$data['sites_id']}}"
                                                                    data-cate="{{$data['category_id']}}"
                                                                    data-status="{{$data['is_send']}}"
                                                                    data-pubtime="{{$data['pubtime']}}"
                                                                    data-url="{{route('sendlist.update',$data->id)}}">
                                                                <i class="fa fa-pencil" aria-hidden="true"></i> 编辑
                                                            </button>
                                                        @endif
                                                        <form action="{{ route('sendlist.destroy', $data['id']) }}"
                                                              method="post"
                                                              style="display: inline-block;">
                                                            {{ csrf_field() }} {{ method_field('DELETE') }}
                                                            <button type="submit" data-delete="{{$data['id']}}"
                                                                    class="btn btn-orange btn-xs waves-effect waves-light">
                                                                <i class="fa fa-trash" aria-hidden="true"></i> 删除
                                                            </button>
                                                        </form>
                                                    </td>
                                                </tr>
                                            @endforeach
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>

            <div class="col-md-3">
                <a href=""
                   class="btn btn-danger btn-mail-main btn-block margin-bottom-20 waves-effect waves-light">站点查看</a>
                <div class="box box-solid">
                    <div class="box-body">
                        <ul class="nav nav-pills nav-stacked">
                            @foreach($sites as $site)
                                <li>
                                    <a href="{{route('sendlist.index',['site'=>$site->id])}}">
                                        <i class="fa fa-inbox"></i> {{$site->name}}
                                        <span class="label-right bg-info pull-right">{{$site->sendlists()->count()}}</span>
                                    </a>
                                </li>
                            @endforeach
                        </ul>
                    </div>
                    <!-- /.box-body -->
                </div>
                <!-- /. box -->
            </div>
            <!-- /.col-lg-4 col-xs-12 -->
        </div>
        <!-- /.row small-spacing -->
    </div>
    <!-- /.main-content -->
</div>
<!--/#wrapper -->
<div class="modal fade" id="addTask" tabindex="-1" role="dialog" aria-labelledby="addTaskLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <form method="POST" action="{{route('sendlist.store')}}">
                {{ csrf_field() }}
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title" id="addTaskLabel">Add模版</h4>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <div class="col-md-12">
                            <div class="form-group">
                                <label for="slug">选择站点</label>
                                <select class="form-control" name="sites_id" id="cat" required>
                                    @foreach($sites as $site)
                                        <option value="{{$site->id}}">{{$site->name}}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="form-group">
                                <label for="slug">选择分类</label>
                                <select class="form-control" name="category_id" id="" required>
                                    @foreach($cates as $cate)
                                        <option value="{{$cate->id}}">{{$cate->name}}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="form-group">
                                <label for="slug">发布时间</label>
                                <div class="input-group">
                                    <input type="text" name="publish_time" class="form-control" autocomplete="off"
                                           placeholder="mm/dd/yyyy"
                                           id="datepicker-autoclose" required>
                                    <span class="input-group-addon bg-primary text-white"><i class="fa fa-calendar"></i></span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default waves-effect waves-light" data-dismiss="modal">取消
                    </button>
                    <button type="submit" class="btn btn-primary waves-effect waves-light">添加</button>
                </div>
            </form>
        </div>
    </div>
</div>

<div class="modal fade" id="editstartend" tabindex="-1" role="dialog" aria-labelledby="editstartendLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <form id="editForm" method="POST" action="">
                {{ csrf_field() }}
                {{ method_field('put') }}
                {{--<input type="hidden" name="_method" value="put">--}}
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title" id="addTaskLabel">Add模版</h4>
                </div>
                <div class="modal-body">
                    <div class="row">

                        <div class="col-md-12">
                            <div class="form-group">
                                <label for="slug">选择站点</label>
                                <select class="form-control" name="sites_id" required>
                                    @foreach($sites as $site)
                                        <option value="{{$site->id}}">{{$site->name}}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="form-group">
                                <label for="slug">选择分类</label>
                                <select class="form-control" name="category_id" required>
                                    @foreach($cates as $cate)
                                        <option value="{{$cate->id}}">{{$cate->name}}</option>
                                    @endforeach
                                </select>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <div class="form-group">
                                <label for="slug">发布时间</label>
                                <div class="input-group">
                                    <input type="text" name="publish_time" autocomplete="off" class="form-control"
                                           placeholder="mm/dd/yyyy"
                                           id="datepicker2" required>
                                    <span class="input-group-addon bg-primary text-white"><i class="fa fa-calendar"></i></span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="modal-footer">
                    <button type="button" class="btn btn-default waves-effect waves-light" data-dismiss="modal">取消
                    </button>
                    <button type="submit" class="btn btn-primary waves-effect waves-light">更改</button>
                </div>
            </form>
        </div>
    </div>
</div>
@endsection @section('scriptsafter') @parent
<script>
    $('.editbtn').on('click', function () {
        var button = $(this)
        var id = button.data('id')
        var site = button.data('site')
        var cate = button.data('cate')
        var status = button.data('status')
        var pubtime = button.data('pubtime')
        var url = button.data('url')
        var modal = $("#editForm");
        modal.attr("action", url);
        modal.find('select[name=sites_id]').val(site);
        modal.find('select[name=category_id]').val(cate);
        modal.find('input[name=publish_time]').val(pubtime);
        modal.find('.modal-title').text('修改id为' + id + '的内容');
        $('#datepicker2').datepicker({
            autoclose: true,
            todayHighlight: true,
        });
    })
    $('#example2').DataTable({
        "language": {
            "lengthMenu": "每页 _MENU_ 条记录",
            "zeroRecords": "没有找到记录",
            "info": "第 _PAGE_ 页 ( 总共 _PAGES_ 页 )",
            "infoEmpty": "无记录",
            "infoFiltered": "(从 _MAX_ 条记录过滤)"
        },
        'ordering': false
    });
</script>
@endsection